﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using VM.Common.Result;
using VM.Entity.EntityMap.DataBase;
using VM.Entity.EntityMap.Topic;
using VM.IBLL.DataBase;
using VM.WebCore.Jwt;
using VM.WebCore.SwaggerExtend;
using VM.Wechat;

namespace VM.WebAPI.Controllers
{


    /// <summary>
    /// 数据字典相关控制器
    /// </summary>
    [Route("api/dataBase")]
    [ApiController]
    public class DataBaseController : ControllerBase
    {
        private readonly IDataBaseBLL _IDataBaseBLL;
        private readonly IJWTService _IJWTService;
        private readonly IHttpContextAccessor _HttpContextAccessor;


        public DataBaseController(IJWTService iJWTService, IDataBaseBLL iDataBaseBLL, IHttpContextAccessor httpContextAccessor)
        {

            _IDataBaseBLL = iDataBaseBLL;
            _IJWTService = iJWTService;
            _HttpContextAccessor = httpContextAccessor;
        }



        /// <summary>
        /// 添加数据字典类型 PC
        /// </summary>
        /// <param name="sys_topic">话题信息</param>
        /// <returns></returns>
        [HttpPost]
        [Authorize]//要求通过授权才行---只要能鉴权成功，都能通过]
        [Route("addDataBaseType")]
        [ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(ApiVersions.V1))]
        public ApiDataResult<sys_dataBaseType> addDataBaseType(sys_dataBaseType obj)
        {
            return _IDataBaseBLL.addDataBaseType(obj);
        }



        /// <summary>
        /// 获取数据字典类型列表，   PC+PHONE
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Authorize]//要求通过授权才行---只要能鉴权成功，都能通过]
        [Route("getDataBaseTypeList")]
        [ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(ApiVersions.V1))]
        public ApiDataResult<PagingData<sys_dataBaseType>> getDataBaseTypeList(string? TypeName = "", int pageIndex = 1, int pageSize = 100)
        {
            //校验验证码是否可用，如果可用，返回true
            ApiDataResult<PagingData<sys_dataBaseType>> Res = _IDataBaseBLL.getDataBaseTypeList(TypeName, pageSize, pageIndex);
            return Res;
        }




        /// <summary>
        /// 添加数据字典 PC
        /// </summary>
        /// <param name="sys_topic">话题信息</param>
        /// <returns></returns>
        [HttpPost]
        [Authorize]//要求通过授权才行---只要能鉴权成功，都能通过]
        [Route("addDataBase")]
        [ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(ApiVersions.V1))]
        public ApiDataResult<sys_dataBase> addDataBase(sys_dataBase obj)
        {

            return _IDataBaseBLL.addDataBase(obj);

        }



        /// <summary>
        /// 获取数据字典列表，   PC+PHONE
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Authorize]//要求通过授权才行---只要能鉴权成功，都能通过]
        [Route("getDataBaseList")]
        [ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(ApiVersions.V1))]
        public ApiDataResult<PagingData<sys_dataBase>> getDataBaseList(string? name = "",int parentId=0, int pageIndex = 1, int pageSize = 100)
        {
            //校验验证码是否可用，如果可用，返回true
            ApiDataResult<PagingData<sys_dataBase>> Res = _IDataBaseBLL.getDataBaseList(name, parentId, pageSize, pageIndex);
            return Res;
        }









    }
}
